<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %> 
<%@page import = "com.db4o.ext.ExtObjectContainer" %>
<%@page import = "com.db4o.servlet.Db4oServlet" %>
<%@page import = "facades.*" %>
<%@page import = "auser.*" %>
<%@page import = "java.util.*" %>
<%@page import = "java.lang.reflect.*" %>
<%@ taglib prefix="t"  tagdir="/WEB-INF/tags/template"  %>
<%@ taglib prefix="h"  tagdir="/WEB-INF/tags/html"  %>
<%@ taglib prefix="db4o"  tagdir="/WEB-INF/tags/db4o" %>
<% ExtObjectContainer co =null;   %> 		
<% List <com.spaceprogram.db4o.sql.Result> res =null; %> 		

<c:if test="${param.action=='Carica'}">
	<% Class classe = Class.forName("auser."+ request.getParameter("classe"));  
	   Db4oCareTaker db4oct = new Db4oCareTaker(session,request.getParameter("circolo"));  
	   co = db4oct.getContainer();  		
	    
	   Field[] fields = classe.getDeclaredFields();  
	   pageContext.setAttribute("objects",co.query(classe));  	
	   session.setAttribute("wrkClass",classe);  	
	   session.setAttribute("fields",fields);  	
	   pageContext.setAttribute("container",co);
	   
	%>	
		 
		 
</c:if>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet"  href="<%=request.getContextPath()%>/css/display.css" type="text/css" media="screen" />
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/autocomplete.js"></script>
<script src="<%=request.getContextPath()%>/js/form.js"></script> 
<script src="<%=request.getContextPath()%>/js/input01.js"></script> 
<script src="<%=request.getContextPath()%>/js/tabs.js"></script>

<title>Gestione Auser - Inserimento scrittura contabile</title> 

<link rel="stylesheet" href="<%=request.getContextPath()%>/css/tabs.css" type="text/css" media="print, projection, screen" />
</head>
<body>
	 
	<form method="GET" action="?">
		 
		<h:select selected="${param.circolo}" label="Circolo" id="circolo"   keys="padova,belluno"/><br>
		<h:select selected="${param.classe}" label="Classe" id="classe"   keys="Accompagnamento,ParametersPDoppia,MovimentoBar,Counters,VoceDiPrimaNota,ScritturaDiPrimaNota,PianoDeiConti,Comune,AccantonamentoBar,Circolo,Utente,Socio,Tessera"/><br>
		<input type="submit" id="action" name="action" value="Carica">
	
	 	<br>
	 	<c:if test="${param.action=='Carica'}">
	 	 
		 
		<table border="1" cellpadding="4">		
			<tr><th>&nbsp;<th>&nbsp;<th>Id
			<c:forEach items="${fields}" var="col" varStatus="s">
				<th>${col.name}  
			</c:forEach>
			 
			<c:forEach items="${objects}" var="elem" varStatus="s"> 
				<tr><td>
						<db4o:getid container="${container}" object="${elem}" var="db4oId" /> 
						<a href='loader.jsp?id=${db4oId}&classe=${param.classe}&circolo=${param.circolo}'>
							[edit] 
						</a>
					<td>
						<a onclick="return confirm('Cancello?');"  href='delete.jsp?id=${db4oId}&classe=${param.classe}&circolo=${param.circolo}'>
							[elimina]	 
						</a>
					<td>${db4oId}
				<c:forEach items="${fields}" var="col" varStatus="s">
					<c:if test="${col.name!='circolo'}"> <td nowrap>${elem[col.name]} &nbsp;  </c:if>
					<c:if test="${col.name=='circolo'}"> <td nowrap>${elem[col.name].descrizione} - ${elem[col.name].indirizzo} &nbsp;  </c:if>
				</c:forEach> 
			</c:forEach>
		</table>
		</c:if>
	</form>
</body>
</html>
